/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package geradorquestoesprova;

import GUI.SistemaMainGUI;
import bo.DisciplinaBO;
import entidades.Disciplina;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import logic.XMLer;

/**
 *
 * @author Ricardo
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException, Exception {
        List<Disciplina> disciplina = new ArrayList<Disciplina>();
        disciplina = XMLer.lerDados();
        DisciplinaBO.getInstance().carregaDisciplinas(disciplina);
        SistemaMainGUI f = new SistemaMainGUI();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setVisible(true);
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    XMLer.escreverDados(DisciplinaBO.getInstance().listar());
                } catch (IOException ex) {
                    Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                } catch (Exception ex) {
                    Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }));
    }
}